home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-107.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  43.5 KB  |  1,179 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Tue, 09 Jun 92       Volume 1 : Issue 107
  2.  
  3. Today's Topics:
  4.  
  5.     Color WDEF's???
  6.     ThinkC
  7.  
  8.  
  9. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  10.  
  11. These digests are available (by using FTP, account anonymous, your email
  12. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  13. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  14. Questions list.  The last several issues of the digest are available from
  15. sumex-aim.stanford.edu as well.
  16.  
  17. These digests are also available via email.  Just send a note saying that you
  18. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  19. automatically receive each new digest as it is created.
  20.  
  21. The digest is a collection of articles from the internet newsgroup comp.sys.
  22. mac.programmer.  It is designed for people who read c.s.m.p. semi-regularly
  23. and want an archive of the discussions.  If you don't know what a newsgroup
  24. is, you probably don't have access to it.  Ask your systems administrator(s)
  25. for details.  (This means you can't post questions to the digest.)
  26.  
  27. The articles in these digests are taken directly from comp.sys.mac.programmer.
  28. They are not edited; all articles included in this digest are in their original
  29. posted form.  The only articles that are -not- included in these digests are
  30. those which didn't receive any replies (except those that give information
  31. rather than ask a question).  All replies to each article are concatenated
  32. onto the original article in the order in which they were received.  Article
  33. threads are not added to the digests until the last article added to the
  34. thread is at least one month old (this is to ensure that the thread is dead
  35. before adding it to the digests).
  36.  
  37. Send administrative mail to mkelly@cs.uoregon.edu.
  38.  
  39. -------------------------------------------------------
  40.  
  41. From: opus@iear.arts.rpi.edu (Christopher S. Eplett)
  42. Subject: Color WDEF's???
  43. Organization: Rensselaer Polytechnic Institute, Troy NY
  44. Date: Wed, 22 Apr 1992 19:09:50 GMT
  45.  
  46. Hello out there, 
  47.  
  48.     I have just entered into the world of WDEF's and have been 
  49.     successful implementing a B&W WDEF, but have been having problems
  50.     working with the WMgrCPort ( or whatever... )
  51.  
  52.     Could somone point me to some sample color WDEF code that shows
  53.     me how to do this sort of thing correctly? IM V is woefully
  54.     terse on this particular topic... :)
  55.  
  56.         Thanks in advance,
  57.         Christopher Hoek Eplett
  58.         opus@iear.arts.rpi.edu
  59.  
  60.     "We are flesh and blood! Not Wax!"  - Commander Hoek, Ren & Stimpy
  61.  
  62. +++++++++++++++++++++++++++
  63.  
  64. From: mlanett@void.ncsa.uiuc.edu (Mark Lanett)
  65. Organization: University of Illinois at Urbana
  66. Date: Wed, 22 Apr 1992 21:19:36 GMT
  67.  
  68. opus@iear.arts.rpi.edu (Christopher S. Eplett) writes:
  69.  
  70. >Hello out there, 
  71.  
  72. >    I have just entered into the world of WDEF's and have been 
  73. >    successful implementing a B&W WDEF, but have been having problems
  74. >    working with the WMgrCPort ( or whatever... )
  75.  
  76. >    Could somone point me to some sample color WDEF code that shows
  77. >    me how to do this sort of thing correctly? IM V is woefully
  78. >    terse on this particular topic... :)
  79.  
  80. Apple makes the source code to their WDEFs/CDEFs available on their ftp server.
  81. There is also pascal code doing a colod CDEf in a snippet, and maybe more source
  82. on the developer's CDs. I believe also that the NeXT WDEF came with source
  83. (well, that's b&w, but there was a color version, and the source for that may
  84. also be around).
  85.  
  86. Sorry I can't be more specific as to locations, developer CDs and ftp.apple.com
  87. are pretty large to search through. I once had the source for every *DEF I could
  88. find, I don't know why, but tossed it all recently.
  89.  
  90. Alas, a grep of wuarchive's info-mac shadow doesn't show the NeXT WDEF. I don't
  91. know where you'd find it.
  92. - -- 
  93. Mark Lanett, Software Tools Group, NCSA; mlanett@uiuc.edu; NCSA.STG (AppleLink)
  94.  
  95. +++++++++++++++++++++++++++
  96.  
  97. From: jpugh@apple.com (Jon Pugh)
  98. Date: 1 May 92 19:48:34 GMT
  99. Organization: Apple Co.
  100.  
  101. In article <mlanett.703977576@void>, mlanett@void.ncsa.uiuc.edu (Mark Lanett) writes:
  102. >
  103. > Apple makes the source code to their WDEFs/CDEFs available on their ftp server.
  104.  
  105. Wrong.  Apple makes a "sample" WDEF available.  It is not the real one but a
  106. completely functional duplicate.
  107.  
  108. Jon
  109.  
  110. +++++++++++++++++++++++++++
  111.  
  112. From: ksand@apple.com (Kent Sandvik)
  113. Date: 3 May 92 22:17:45 GMT
  114. Organization: MacDTS Mongols
  115.  
  116. In article <24297@goofy.Apple.COM>, jpugh@apple.com (Jon Pugh) writes:
  117. > In article <mlanett.703977576@void>, mlanett@void.ncsa.uiuc.edu (Mark Lanett)
  118. writes:
  119. > >
  120. > > Apple makes the source code to their WDEFs/CDEFs available on their ftp
  121. server.
  122. > Wrong.  Apple makes a "sample" WDEF available.  It is not the real one but a
  123. > completely functional duplicate.
  124.  
  125. It's the 6.0.x version - and yes we should clean up the 7.0.x one for
  126. distribution.
  127. I've taken a note about this.
  128.  
  129. Cheers,
  130. Kent/DTS
  131.  
  132. +++++++++++++++++++++++++++
  133.  
  134. From: mlanett@void.ncsa.uiuc.edu (Mark Lanett)
  135. Date: 4 May 92 19:26:31 GMT
  136. Organization: University of Illinois at Urbana
  137.  
  138. jpugh@apple.com (Jon Pugh) writes:
  139.  
  140. >Wrong.  Apple makes a "sample" WDEF available.  It is not the real one but a
  141. >completely functional duplicate.
  142.  
  143. Not the real one but a completely functional duplicate? Lesse, if the duplicate
  144. wan't functional, wouldn't that have some implications for the "real" one? :-)
  145. Or, how is a duplicate less real? (Ok, ok, I'll shut up).
  146. - -- 
  147. Mark Lanett, NCSA Software Development - mlanett@uiuc.edu
  148.  
  149. +++++++++++++++++++++++++++
  150.  
  151. From: jpugh@apple.com (Jon Pugh)
  152. Date: 8 May 92 20:04:40 GMT
  153. Organization: Apple Co.
  154.  
  155. In article <mlanett.705007591@void>, mlanett@void.ncsa.uiuc.edu (Mark Lanett) writes:
  156. > jpugh@apple.com (Jon Pugh) writes:
  157. > >Wrong.  Apple makes a "sample" WDEF available.  It is not the real one but a
  158. > >completely functional duplicate.
  159. > Not the real one but a completely functional duplicate? Lesse, if the duplicate
  160. > wan't functional, wouldn't that have some implications for the "real" one? :-)
  161. > Or, how is a duplicate less real? (Ok, ok, I'll shut up).
  162.  
  163.  
  164. I lied.  It's not completely functional.  I also understand that the b&w
  165. sample is the "actual" sys6 WDEF.  But what do I know?  I'm just blowing
  166. smoke.
  167.  
  168. Jon
  169.  
  170. ---------------------------
  171.  
  172. From: cyor@watdragon.waterloo.edu (               )
  173. Subject: ThinkC
  174. Date: 18 Mar 92 16:27:37 GMT
  175. Organization: University of Waterloo
  176.  
  177. Hi there!
  178.  
  179. I have some simple questions regarding to programming languages for the
  180. Macintosh PowerBook 170.
  181.  
  182. * Is there any Prolog or Lisp available for such machine.
  183.  
  184. * What is the different between ANSI-C and ThinkC?
  185.   (If I want to do my assignments under ThinkC and then transfer the file
  186.    to the UNIX machine in the university and compile the code under the 
  187.    gcc command, will there be any problem?)
  188.  
  189. * In sum, are there any compilers for Prolog, Lisp and C on the Mac that
  190.    are fully compatitable to each other.?
  191.  
  192. *  BTW, does anybody out ther have any experience  with A/UX?
  193.  
  194.  
  195. Thanks...
  196.  
  197. +++++++++++++++++++++++++++
  198.  
  199. From: jerome@ee.fit.edu (Jerome Chan)
  200. Date: 23 Mar 92 06:39:02 GMT
  201. Organization: Florida Tech, CP/EE Dept.
  202.  
  203. Is there an InterNet ThinkC help guide out ther somewhere
  204. for newbies? Tips like CDirector objects have their own
  205. Cwindow instance (am I using the correct terminlogy) and
  206. you don't have to waste time making a Cwindow object for
  207. it? (Which I spent about an hour before I found out.)
  208.  
  209. Anyone?
  210.  
  211.  
  212. - --
  213.  The Evil Tofu
  214.  
  215.  
  216. +++++++++++++++++++++++++++
  217.  
  218. From: jerome@ee.fit.edu (Jerome Chan)
  219. Date: 23 Mar 92 06:42:10 GMT
  220. Organization: Florida Tech, CP/EE Dept.
  221.  
  222. Does anyone have any suggestions on how 
  223. File Transfer Protocols ought to be implemented
  224. as Think C Classes? I think it's easier than
  225. trying to write file transfer tools.
  226.  
  227. Should this class insert a chore into a CApplications
  228. assignidlechore list?
  229.  
  230.  
  231. - --
  232.  The Evil Tofu
  233.  
  234.  
  235. +++++++++++++++++++++++++++
  236.  
  237. From: cbenda@unccvax.uncc.edu (carl m benda)
  238. Date: 16 Apr 92 21:59:23 GMT
  239. Organization: University of NC at Charlotte
  240.  
  241. I am having major dificulties trying to run a small program
  242. which does file I/o Using standard C function calls.. in
  243. particular fputc gives me a "bus error" inside ANSI-small
  244. when running the code under System 7.0.. Any clues..
  245.  
  246. Much thanks for any direct response to me!
  247. cbenda@unccvax.uncc.edu
  248.  
  249. /Carl
  250.  
  251. +++++++++++++++++++++++++++
  252.  
  253. From: akhiani@ricks.enet.dec.com (Homayoon Akhiani)
  254. Organization: Digital Equipment Corporation
  255. Date: Tue, 21 Apr 1992 23:12:49 GMT
  256.  
  257.  
  258.  
  259. I have the following piece of code, running on IIsi w/ Sys7 Tuneup 1.1.1 
  260. using ThinkC (I got it last month so I assume it is the lastest version)
  261.  
  262. malloc is not returning NULL, However when I step through the code with the 
  263. debugger, for both L and m, malloc returns some number like 0xFFFFF***
  264.  
  265. When I do examine (in the ThinkC debugger) *m or *L I get "Bus Error"
  266.  
  267. If I use "GO" the program will halted in the for loop (accessing L[0]) 
  268. with bus error.
  269.  
  270. Is there a bug in malloc in ThinkC?
  271.  
  272.  
  273. #define MSIZE   10000  
  274. unsigned int    *m;        
  275. char            **L;       
  276.  m = (unsigned *)malloc((unsigned)MSIZE*sizeof(unsigned int));
  277.  assert(m!=NULL);
  278.  L = (char **)malloc((unsigned)MSIZE*sizeof(char *));
  279.  assert(L!=NULL);
  280.  for(i=0;i<MSIZE;i++) L[i]=NULL;
  281.  
  282.  
  283.  
  284. - -------------------------------------------------------------------------------
  285. Homayoon Akhiani                               "Turning Ideas into ... Reality"
  286. Digital Equipment Corporation                        "Alpha, The New Beginning"
  287. 77 Reed Rd. Hudson, MA 01701            "All Rights Reserved. Copyright(c)1992"
  288. Email: akhiani@ricks.enet.dec.com        "It is me speaking, not my company"
  289. - -------------------------------------------------------------------------------
  290.  
  291. +++++++++++++++++++++++++++
  292.  
  293. From: bell@apple.com (Mike Bell)
  294. Date: 23 Apr 92 19:18:10 GMT
  295. Organization: Apple Computer, Inc.
  296.  
  297. In article <1992Apr21.231249.10249@ryn.mro4.dec.com>, 
  298. akhiani@ricks.enet.dec.com (Homayoon Akhiani) writes:
  299. > Path: 
  300. apple!constellation!munnari.oz.au!mips!decwrl!deccrl!news.crl.dec.com!hollie.r
  301. dg.dec.co
  302. > m!ryn.mro4.dec.com!ricks.enet.dec.com!akhiani
  303. > From: akhiani@ricks.enet.dec.com (Homayoon Akhiani)
  304. > Newsgroups: comp.sys.mac.programmer
  305. > Subject: ThinkC and malloc problem
  306. > Message-ID: <1992Apr21.231249.10249@ryn.mro4.dec.com>
  307. > Date: 21 Apr 92 23:12:49 GMT
  308. > Sender: news@ryn.mro4.dec.com (USENET News System)
  309. > Reply-To: akhiani@ricks.enet.dec.com (Homayoon Akhiani)
  310. > Organization: Digital Equipment Corporation
  311. > Lines: 33
  312. > I have the following piece of code, running on IIsi w/ Sys7 Tuneup 1.1.1 
  313. > using ThinkC (I got it last month so I assume it is the lastest version)
  314. > malloc is not returning NULL, However when I step through the code with the 
  315. > debugger, for both L and m, malloc returns some number like 0xFFFFF***
  316. > When I do examine (in the ThinkC debugger) *m or *L I get "Bus Error"
  317. > If I use "GO" the program will halted in the for loop (accessing L[0]) 
  318. > with bus error.
  319. > Is there a bug in malloc in ThinkC?
  320. > #define MSIZE   10000  
  321. > unsigned int    *m;        
  322. > char            **L;       
  323. >  m = (unsigned *)malloc((unsigned)MSIZE*sizeof(unsigned int));
  324. >  assert(m!=NULL);
  325. >  L = (char **)malloc((unsigned)MSIZE*sizeof(char *));
  326. >  assert(L!=NULL);
  327. >  for(i=0;i<MSIZE;i++) L[i]=NULL;
  328. >  
  329. > ----------------------------------------------------------------------------
  330. - ---
  331. > Homayoon Akhiani                               "Turning Ideas into ... 
  332. Reality"
  333. > Digital Equipment Corporation                        "Alpha, The New 
  334. Beginning"
  335. > 77 Reed Rd. Hudson, MA 01701            "All Rights Reserved. 
  336. Copyright(c)1992"
  337. > Email: akhiani@ricks.enet.dec.com        "It is me speaking, not my company"
  338. > ----------------------------------------------------------------------------
  339. - ---
  340.  
  341.  
  342.  
  343. If you don't include the header <stdlib.h> in your program, it will still 
  344. compile, but malloc will behave just as you describe. It passes back a non-
  345. zero (but garbage) pointer, that then bus errors. It is mentioned in the 
  346. manual, but it still seems like weird behavior to me.
  347.  
  348.  
  349.  
  350.    -Mike
  351.  
  352.  
  353.  
  354.  
  355. *****************************************
  356.  
  357. Mike Bell                                            email: bell@apple.com
  358. 68000 High Performance Software Group
  359. MS 60-CS
  360. Apple Computer, Inc.
  361. 20525 Mariani Ave.
  362. Cupertino, CA 95014
  363.  
  364. *****************************************
  365.  
  366. +++++++++++++++++++++++++++
  367.  
  368. From: jrrk@camcon.co.uk (Jonathan Kimmitt)
  369. Date: 24 Apr 92 12:45:26 GMT
  370. Organization: Cambridge Consultants Ltd., Cambridge, UK
  371.  
  372. >> I have the following piece of code, running on IIsi w/ Sys7 Tuneup 1.1.1 
  373. >> using ThinkC (I got it last month so I assume it is the lastest version)
  374. >> 
  375. >> malloc is not returning NULL, However when I step through the code with the 
  376. >> debugger, for both L and m, malloc returns some number like 0xFFFFF***
  377. >> 
  378. >> When I do examine (in the ThinkC debugger) *m or *L I get "Bus Error"
  379. >> 
  380. >> If I use "GO" the program will halted in the for loop (accessing L[0]) 
  381. >> with bus error.
  382. >> 
  383. >> Is there a bug in malloc in ThinkC?
  384. >> 
  385. >If you don't include the header <stdlib.h> in your program, it will still 
  386. >compile, but malloc will behave just as you describe. It passes back a non-
  387. >zero (but garbage) pointer, that then bus errors. It is mentioned in the 
  388. >manual, but it still seems like weird behavior to me.
  389.  
  390. - --- end include text ---
  391.  
  392. One of the most annoying (and non-portable) features of C is that
  393. unprototyped functions will default to int for all input and output
  394. parameters. The size of int is not defined but is usually 32 bits on
  395. workstations and 16 bits for most PC implementations, and for THINK_C
  396. However pointers for a 68000 will be 32 bits whatever.
  397. This means code running on a 32 bit workstation will work passing
  398. pointers to subroutines without declaring the parameters of those functions
  399. unfortunately THINK_C will not work because it will assume 16 bits is 
  400. passed to malloc if not declared to take a size_t (=pointer size (=32 bits))
  401. parameter.The compiler will also need to know that malloc is supposed
  402. to return a void *, otherwise it will assume an integer(16 bits)
  403.  
  404. The moral of this is dont expect any C program to work in THINK C
  405. unless you have checked 'check pointer types' and 'require prototypes'
  406. in your preferences section. This will prevent successful compilation
  407. if all required header files are not present.
  408.  
  409. If you port a program from unix you will probably find any
  410. %d and %x statements in printf and scanf statements
  411. will need to be changed to %ld and %lx
  412. and occurences of int will need to be changed to long int
  413. where necessary.
  414.  
  415. The compiler will not warn you if args to printf/scanf are the wrong size
  416.  
  417. to test portability of a program or lack of it using gnu-c
  418. you can use gcc -mshort -Wall
  419. this will generally cause the compilation to fail and or the executable not to
  420. work, unless carefully written
  421.  
  422. Things would be nuch nicer if THINK C understood that an int is assumed
  423. to be 32 bits by most programmers, whatever the natural size of 68000
  424. code ought to be ...
  425.  
  426. +++++++++++++++++++++++++++
  427.  
  428. From: russotto@eng.umd.edu (Matthew T. Russotto)
  429. Date: Fri, 24 Apr 92 14:02:42 GMT
  430. Organization: College of Engineering, University of Maryland, College Park
  431.  
  432. In article <20286@io.camcon.co.uk> jrrk@camcon.co.uk (Jonathan Kimmitt) writes:
  433.  
  434. >If you port a program from unix you will probably find any
  435. >%d and %x statements in printf and scanf statements
  436. >will need to be changed to %ld and %lx
  437. >and occurences of int will need to be changed to long int
  438. >where necessary.
  439.  
  440. >
  441. >Things would be nuch nicer if THINK C understood that an int is assumed
  442. >to be 32 bits by most programmers, whatever the natural size of 68000
  443. >code ought to be ...
  444.  
  445. Use THINK C 5.0.x-- it allows either 2-byte or 4-byte ints--
  446. programmers choice.
  447.  
  448. - -- 
  449. Matthew T. Russotto    russotto@eng.umd.edu    russotto@wam.umd.edu
  450. Some news readers expect "Disclaimer:" here.
  451. Just say NO to police searches and seizures.  Make them use force.
  452. (not responsible for bodily harm resulting from following above advice)
  453.  
  454. +++++++++++++++++++++++++++
  455.  
  456. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  457. Date: 24 Apr 92 15:43:54 GMT
  458. Organization: Symantec Corp.
  459.  
  460. >>>>> On 24 Apr 92 12:45:26 GMT, jrrk@camcon.co.uk (Jonathan Kimmitt) said:
  461.  
  462.  > Things would be nuch nicer if THINK C understood that an int is
  463.  > assumed to be 32 bits by most programmers, whatever the natural
  464.  > size of 68000 code ought to be ...
  465.  
  466. In C 5.0, there's a compiler option that makes the int type 32 bits
  467. wide. It's called "4-byte ints", and it's described on p. 193 in the
  468. section entitled "Porting Code to THINK C".
  469.  
  470. If you're using ANSI, you must recompile it with the 4-byte ints
  471. option on as well. This will let you format your 32 bit ints using %d,
  472. etc.
  473.  
  474.     -phil
  475. - --
  476.    Phil Shapiro                                   Software Engineer
  477.    Language Products Group                     Symantec Corporation
  478.            Internet: phils@cs.brandeis.edu
  479.  
  480. +++++++++++++++++++++++++++
  481.  
  482. From: potts@itl.itd.umich.edu (Paul Potts)
  483. Organization: Instructional Technology Laboratory, University of Michigan
  484. Date: Fri, 24 Apr 92 15:57:55 GMT
  485.  
  486. In article <20286@io.camcon.co.uk> jrrk@camcon.co.uk (Jonathan Kimmitt) writes:
  487. >
  488. (stuff about 32-bit pointers removed)...
  489. >
  490. >Things would be nuch nicer if THINK C understood that an int is assumed
  491. >to be 32 bits by most programmers, whatever the natural size of 68000
  492. >code ought to be ...
  493.  
  494. This is a generic problem with C and has been pretty well addressed by the
  495. changes to ANSI. Of course, it is still up to the developer to write portable
  496. code. Apple and THINK have worked to remove the incompatibilites between
  497. their compilers, and Toolbox routines are no longer declared to use the "int"
  498. type, since it is ambiguous. They use "short" and "long" instead.
  499.  
  500. Writing portable code is difficult. For a good example of how difficult, take
  501. a look at the book _The_C_Standard_Library_ by, I believe, Plauger (my book
  502. is at home). The code is a good object lesson in how difficult it is.
  503.  
  504. The "natural size" for a 68000 is sort of ambiguous. Does one go with the
  505. register size, 32 bits, or with the size of the data bus on the original
  506. 68000? On a 68000, MOVE.W is quicker than MOVE.L, but on a machine with
  507. a 32-bit data bus (most of the Mac II line) they are (I believe) equivalent
  508. in speed. THINK took one approach, MPW the other. THINK has now been
  509. modified so that all the libraries can be built using 32-bit or 16-bit ints,
  510. and works either way. The upshot of this all is that it works now, and code
  511. is very easily transported between MPW and THINK.
  512.  
  513. I don't know about most programmers, but I think it is kind of unfair to
  514. say that "int" is generally thought of as 32-bits. All K&R and ANSI say is
  515. that it falls within a certain range compared to the other types. If
  516. programmers are making assumptions about the integer size which are non-
  517. portable, they are writing non-portable code.
  518.  
  519. I don't want to turn this into a war, I just thought I'd throw my two cents
  520. in. Even the best of us wind up writing non-portable code at times (often
  521. there is no good alternative). However, never using "int" helps.
  522. Your suggestions for requiring prototypes, etc. will also help.
  523.  
  524. - -- 
  525. Paul Potts - potts@itl.itd.umich.edu
  526. Un damne' descendant sans lampe,/ Au bord d'un gouffre dont l'odeur
  527. Trahit l'humide profondeur,/ D'e'ternels escaliers sans rampe... 
  528.    -Baudelaire on DOS/Windows programming   
  529.  
  530. +++++++++++++++++++++++++++
  531.  
  532. From: meharp01@vlsi.louisville.edu (Michael Harpe)
  533. Organization: University of Louisville
  534. Date: Fri, 24 Apr 1992 18:55:16 GMT
  535.  
  536. jrrk@camcon.co.uk (Jonathan Kimmitt) writes:
  537.  
  538. >One of the most annoying (and non-portable) features of C is that
  539. >unprototyped functions will default to int for all input and output
  540. >parameters. The size of int is not defined but is usually 32 bits on
  541. >workstations and 16 bits for most PC implementations, and for THINK_C
  542. >However pointers for a 68000 will be 32 bits whatever.
  543. >This means code running on a 32 bit workstation will work passing
  544. >pointers to subroutines without declaring the parameters of those functions
  545. >unfortunately THINK_C will not work because it will assume 16 bits is 
  546. >passed to malloc if not declared to take a size_t (=pointer size (=32 bits))
  547. >parameter.The compiler will also need to know that malloc is supposed
  548. >to return a void *, otherwise it will assume an integer(16 bits)
  549.  
  550. THANK YOU!  Now I know i'm not crazy.  I had a similar type of problem a couple
  551. of weeks ago.  People told me I just didn't understand C well enough.  I 
  552. thought it was behaving differently on the Mac....
  553.  
  554. >If you port a program from unix you will probably find any
  555. >%d and %x statements in printf and scanf statements
  556. >will need to be changed to %ld and %lx
  557. >and occurences of int will need to be changed to long int
  558. >where necessary.
  559.  
  560. >The compiler will not warn you if args to printf/scanf are the wrong size
  561.  
  562. I had this exact problem and I did what this poster described.  That did 
  563. indeed fix what I was porting.  I think the compiler SHOULD warn you!
  564.  
  565. >to test portability of a program or lack of it using gnu-c
  566. >you can use gcc -mshort -Wall
  567. >this will generally cause the compilation to fail and or the executable not to
  568. >work, unless carefully written
  569.  
  570. >Things would be nuch nicer if THINK C understood that an int is assumed
  571. >to be 32 bits by most programmers, whatever the natural size of 68000
  572. >code ought to be ...
  573.  
  574. Hear, Hear!
  575.  
  576.  
  577. - -- 
  578. - ---------------------------------------
  579. "I will not barf unless i'm sick"
  580.                                    - A Chalkboard from "The Simpsons"
  581.  
  582.  
  583. +++++++++++++++++++++++++++
  584.  
  585. From: rsfinn@concerto.lcs.mit.edu (Russell S. Finn)
  586. Organization: MIT Laboratory for Computer Science
  587. Date: Fri, 24 Apr 1992 22:12:24 GMT
  588.  
  589. In article <1992Apr24.185516.4413@vlsi.louisville.edu>, meharp01@vlsi.louisville.edu (Michael Harpe) writes:
  590. |> jrrk@camcon.co.uk (Jonathan Kimmitt) writes:
  591. |> >If you port a program from unix you will probably find any %d and
  592. |> >%x statements in printf and scanf statements will need to be
  593. |> >changed to %ld and %lx and occurences of int will need to be
  594. |> >changed to long int where necessary.
  595. |> 
  596. |> >The compiler will not warn you if args to printf/scanf are the wrong size
  597. |> 
  598. |> I had this exact problem and I did what this poster described.  That did 
  599. |> indeed fix what I was porting.  I think the compiler SHOULD warn you!
  600.  
  601. In general, the compiler *can't* warn you about this.  Whether or not
  602. you think it's appropriate for the compiler, given:
  603.  
  604.     void foo (void)
  605.     {
  606.         long n = 17L;
  607.         printf ("n = %d", n);
  608.         }
  609.  
  610. to scan the string "n = %d" and determine that since the first
  611. parameter replacement string calls for an "int", but the first
  612. argument is a "long", it should generate an error (and personally I
  613. think that's inappropriate), consider the following case:
  614.  
  615.     void foo (char *s)
  616.     {
  617.         long n = 17L;
  618.         printf (s, n);
  619.         }
  620.  
  621. This is certainly legal and meaningful C code, but there's no way the
  622. compiler can check this.  (Of course, it *could* emit code to
  623. dynamically check the arguments at run-time -- not in *my* C compiler,
  624. thank you.)  
  625.  
  626. On the other hand, the alternative, seen in languages like Modula-2,
  627. is to require a separate procedure call for each item to be output, so
  628. that typechecking may be done (along the lines of "WriteString (s);
  629. WriteLong (n);" etc.  You buys your compiler and you takes your
  630. choice.
  631.  
  632. Typechecking arguments for functions, when the type and number of
  633. their parameters have not been previously declared (as with "printf"),
  634. is a problem which has not been solved by any programming language I'm
  635. aware of.  
  636.  
  637. - -- Russell S. Finn
  638. rsfinn@lcs.mit.edu
  639.  
  640. +++++++++++++++++++++++++++
  641.  
  642. From: keith@taligent.com (Keith Rollin)
  643. Date: 25 Apr 92 02:43:05 GMT
  644. Organization: Taligent
  645.  
  646. > jrrk@camcon.co.uk (Jonathan Kimmitt) writes:
  647. >
  648. > >Things would be nuch nicer if THINK C understood that an int is assumed
  649. > >to be 32 bits by most programmers, whatever the natural size of 68000
  650. > >code ought to be ...
  651.  
  652. I spent last Christmas vacation doing a close analysis of code generated by
  653. THINK C, MPW C, and GNU C. MPW was about 10% better than GNU because GNU didn't
  654. optimize long branches into short branches. THINK was about 10% better than MPW
  655. because it used 16-bit ints instead of 32-bit ints. THINK code runs a little
  656. faster, too, because you can use 680x0 instructions for math instead of library
  657. routines. So using 16-bit integers is definitely a win.
  658.  
  659. Personally, I don't think that most C programmers assume an int is the same as a
  660. long. *I* don't, and I know that everyone I work with is drilled to not make
  661. that mistake, either. Anyone who _does_ make that assumption is quickly burnt.
  662.  
  663. - --
  664. Keith Rollin
  665. Phantom Programmer
  666. Taligent, Inc.
  667.  
  668.  
  669. +++++++++++++++++++++++++++
  670.  
  671. From: ksand@apple.com (Kent Sandvik)
  672. Date: 26 Apr 92 22:59:42 GMT
  673. Organization: MacDTS Mongols
  674.  
  675. > In article <20286@io.camcon.co.uk> jrrk@camcon.co.uk (Jonathan Kimmitt)
  676. writes:
  677. > >
  678. > (stuff about 32-bit pointers removed)...
  679. > >
  680. > >Things would be nuch nicer if THINK C understood that an int is assumed
  681. > >to be 32 bits by most programmers, whatever the natural size of 68000
  682. > >code ought to be ...
  683.  
  684. Argh, who assumes what about ints, they could be anything between an 8-bit
  685. micro and a Cray? I never use ints, nope, (un)signed longs and shorts are
  686. the way to go, even better, typecast everything so it's easier to port
  687. code.
  688.  
  689. Cheers,
  690. Kent
  691.  
  692. +++++++++++++++++++++++++++
  693.  
  694. From: ksand@apple.com (Kent Sandvik)
  695. Date: 27 Apr 92 02:55:33 GMT
  696. Organization: MacDTS Mongols
  697.  
  698. In article <23995@goofy.Apple.COM>, ksand@apple.com (Kent Sandvik) writes:
  699. > > In article <20286@io.camcon.co.uk> jrrk@camcon.co.uk (Jonathan Kimmitt)
  700. > writes:
  701. > > >
  702. > > (stuff about 32-bit pointers removed)...
  703. > > >
  704. > > >Things would be nuch nicer if THINK C understood that an int is assumed
  705. > > >to be 32 bits by most programmers, whatever the natural size of 68000
  706. > > >code ought to be ...
  707. > Argh, who assumes what about ints, they could be anything between an 8-bit
  708. > micro and a Cray? I never use ints, nope, (un)signed longs and shorts are
  709. > the way to go, even better, typecast everything so it's easier to port
  710. > code.
  711.  
  712. Actually, someone might ask, int:s are the most optimal non-floating
  713. variable structure that the compilers generate, why not make use of this?
  714.  
  715. My answer, I rather spend less time with porting, than thinking about
  716. performance in code in the initial stage - without even knowing about
  717. the real bottlenecks.
  718.  
  719. I hope this explained my point of view.
  720.  
  721. Cheers,
  722. Kent
  723.  
  724. +++++++++++++++++++++++++++
  725.  
  726. From: jrrk@camcon.co.uk (Jonathan Kimmitt)
  727. Date: 27 Apr 92 13:22:24 GMT
  728. Organization: Cambridge Consultants Ltd., Cambridge, UK
  729.  
  730. ksand@apple.com (Kent Sandvik) writes:
  731.  
  732. >Argh, who assumes what about ints, they could be anything between an 8-bit
  733. >micro and a Cray? I never use ints, nope, (un)signed longs and shorts are
  734. >the way to go, even better, typecast everything so it's easier to port
  735. >code.
  736.  
  737. I assume our correspondent means by typecasting, typedefining code such as
  738.  
  739. typedef unsigned long ul_t;
  740.  
  741. rather than 
  742.  
  743. ptr = (char *)malloc((long) bytes);
  744.  
  745. where the casts (char *) and (long) are definitely not an increase 
  746. in portability.
  747.  
  748. This was not a declaration of war, nor have I anything against Symantec
  749. whose products I find easy to use.
  750. I was simply saying that one of the defects of the language C itself
  751. is that the default type for parameters and returns for undeclared functions
  752. is the nebulous quantity called int which is the natural size of the machine
  753. for arithmetic etc. and is usually 16 bits or more.
  754. In the days when 64K was a lot, Kernighan & Ritchie would never have imagined 
  755. that a range of machines would arise
  756. with more addressing range than the machines natural word length.
  757. However this is exactly what has happened with Intel's range of processors
  758. and 680X0 compilers that assume int to be 16 bits for the sake of efficiency
  759. and ANSI-C addresses the issue with its size_t type.
  760. There is a large body of C code that was originally written for 
  761. non-ansi compilers which does make the assumption that an int can
  762. contain a pointer, and if it is desired to make any use of such code
  763. it is useful to be able to force your favourite compiler to use an
  764. appropriately large int, and I am glad to be told that THINK C 5.0.X
  765. addresses this issue. If you can't afford the upgrade and don't want the
  766. fag of the 'require prototypes' option, you could change the name of 
  767. malloc in the ANSI library to malloc_ and in <stdlib.h> add the line
  768. #define malloc malloc_
  769. this would cause your compilation to fail if <stdlib.h> is not
  770. included everywhere where it is needed. This is the kind of approach adopted 
  771. in <console.h> and if applied to the whole ANSI library it would have
  772. caused irritation to some users but would have saved many others from
  773. compiling programs with incorrect library call parameters.
  774. Life would be even easier for beginners and hands on first/ read manual later
  775. users if the ANSI function headers were included by default in a similar
  776. way to the precompiled <MacHeaders> file, but we might run the risk of
  777. dispelling the mystique that surrounds the C programming community ...
  778.  
  779. +++++++++++++++++++++++++++
  780.  
  781. From: mikewebb@boston.sinet.slb.com (Mike Webb)
  782. Date: 27 Apr 92 14:12:47 GMT
  783. Organization: Schlumberger Technologies CAD/CAM Division
  784.  
  785.  
  786.      Speaking of odd things with THINKC's (5.0x) compiler settings...
  787.  
  788.      Has anyone else run into a problem with the member function from
  789.      OOPSDEBUG going into an (apparently) infinite loop?  This is 
  790.      definitely compiler option related.  Yesterday, I was working on a     
  791.      numerically intensive OOP (i.e. one that should run about 5x faster 
  792.      with the 6888x option checked, but uses TCL to run the user interface),
  793.      but member was semi-consistently going into an infinite loop.  In my 
  794.      code, member would always hang (before it got into the numerical code),
  795.      but not always in the same place (depended on where breaks were set!).  
  796.      The options I was using were to the effect of:
  797.  
  798.      68881
  799.      68020
  800.      sizeof(int) == 4
  801.      sizeof(double) == 8
  802.      native mode floating point
  803.  
  804.      Re-compiling ANSI and OOPSDEBUG with these options did not help.  
  805.      Reseting the compiler settings to the "factory settings" made the 
  806.      program work, but meant I couldn't use 68881 :-(
  807.  
  808.      Probably the next step is to systematically figure out which compiler
  809.      options cause the problem.
  810.  
  811. +++++++++++++++++++++++++++
  812.  
  813. From: mbrad@athena.mit.edu (Michael R Bradshaw)
  814. Date: 27 Apr 92 17:57:49 GMT
  815. Organization: Massachusetts Institute of Technology
  816.  
  817. In article <1992Apr27.141247.28922@mailhost.bl.cad.slb.com>
  818. mikewebb@boston.sinet.slb.com (Mike Webb) writes:
  819.  
  820.  
  821.  
  822.     Speaking of odd things with THINKC's (5.0x) compiler settings...
  823.  
  824.     Has anyone else run into a problem with the member function from
  825.     OOPSDEBUG going into an (apparently) infinite loop?  This is 
  826.     definitely compiler option related.  Yesterday, I was working on a     
  827.     numerically intensive OOP (... text deleted ...
  828.  
  829.     The options I was using were to the effect of:
  830.  
  831.     68881
  832.     68020
  833.     sizeof(int) == 4
  834.     sizeof(double) == 8
  835.     native mode floating point
  836.  
  837.     Re-compiling ANSI and OOPSDEBUG with these options did not help.  
  838.     Reseting the compiler settings to the "factory settings" made the 
  839.     program work, but meant I couldn't use 68881 :-(
  840.  
  841.     Probably the next step is to systematically figure out which compiler
  842.     options cause the problem.
  843.  
  844. I too had this same problem a while back, but was only using the ANSI
  845. library.  My code was also numerically intensive, and used malloc/free
  846. to allocate temporary storage matrices. When I tried using the PROFILER
  847. and various compinations of 68000/68020/68881 and native floating point
  848. formats, my code would crash at apparently random places.
  849.  
  850. I am fairly certain that I didn't even come close to a low memory
  851. situation or munge the malloc/free arguments and array indices.
  852.  
  853. Any other data points, or solutions out there?
  854.  
  855.  
  856. - --
  857.                     mbrad@athena.mit.edu
  858.                     Michael Bradshaw
  859.                     "Home of the lame .sig file"
  860.  
  861. +++++++++++++++++++++++++++
  862.  
  863. From: jimc@isc-br.ISC-BR.COM (Jim Cathey)
  864. Date: 27 Apr 92 22:25:58 GMT
  865. Organization: ISC-Bunker Ramo, An Olivetti Company
  866.  
  867. In article <20286@io.camcon.co.uk> jrrk@camcon.co.uk (Jonathan Kimmitt) writes:
  868. >Things would be nuch nicer if THINK C understood that an int is assumed
  869. >to be 32 bits by most programmers, whatever the natural size of 68000
  870. >code ought to be ...
  871.  
  872. Things would be nicer still if C programmers didn't assume any such
  873. stupid thing, and would code right in the first place, using forward
  874. declarators for function return values, longs instead of ints for things
  875. that need to be larger than 16 bits, and typedefs for things that have
  876. to be particular sizes (so they can be tuned in a machine-dependant
  877. header file).  And these days, prototypes.  That way, we wouldn't be
  878. having all this trouble in the first place, and we could still get
  879. small, efficient code on smaller machines that would run no slower
  880. on the bigger ones (unlike the other way around).
  881.  
  882. The biggest example of how to do this wrong was a few years ago when
  883. I tried to get PISTOL (Portably Implemented Stack Oriented Language --
  884. a FORTH-like language written in C) ported.  It was written on a 16-bit
  885. int 16-bit pointer Z-80 platform, and I was trying to put it on a
  886. 16-bit int, 32-bit pointer 68000 system.  Yech.  It was the most non-
  887. portable C code I'd ever seen.  Buried deeply within the code were
  888. all sorts of assumptions:  that ints and pointers were the same size,
  889. that said size was 16 bits, and that said entities were little-endian.
  890. There were more.  I gave up.  It truly was that thing we've all heard
  891. about:  assembly language code that happened to be written in C.
  892.  
  893. +----------------+
  894. ! II      CCCCCC !  Jim Cathey
  895. ! II  SSSSCC     !  ISC-Bunker Ramo
  896. ! II      CC     !  TAF-C8;  Spokane, WA  99220
  897. ! IISSSS  CC     !  UUCP: uunet!isc-br!jimc (jimc@isc-br.isc-br.com)
  898. ! II      CCCCCC !  (509) 927-5757
  899. +----------------+
  900.             "PC's --- the junk bonds of the computer industry"
  901.  
  902. +++++++++++++++++++++++++++
  903.  
  904. From: akhiani@rock.enet.dec.com (Homayoon Akhiani)
  905. Date: 27 Apr 92 23:50:49 GMT
  906. Organization: Digital Equipment Corporation
  907.  
  908.  
  909.  Thanks for the replies.
  910.  Adding stdlib.h and switching the compiler to 32 bit int's fixed the problem.
  911.  
  912.  Many of you ask me whay I am not using Newptr, Well, the code that I am trying
  913.  to compile is suppose to be a portable one.
  914.  It should be compile on many platforms. Newptr is Mac thingy.
  915.  
  916.  Now, I am fighting with fopen...
  917.  basically, I trace the program to the fopen call and then the machine hangs!
  918.  
  919.  
  920.  
  921.  
  922. +++++++++++++++++++++++++++
  923.  
  924. From: mikewebb@boston.sinet.slb.com (Mike Webb)
  925. Date: 28 Apr 92 16:05:17 GMT
  926. Organization: Schlumberger Technologies CAD/CAM Division
  927.  
  928. In article <MBRAD.92Apr27135739@e40-008-9.mit.edu>, mbrad@athena.mit.edu (Michael R Bradshaw) writes:
  929. |>
  930. |> ... Discussion of hangs and crashes in numerically intensive OOP
  931. |> with random behavior relating to breakpoint setting, compiler
  932. |> options, member, malloc, ANSI library, ... omitted
  933. |> 
  934. |> Any other data points, or solutions out there?
  935. |> 
  936.  
  937. While not relating to my original problem (hangs in member), I have
  938. run into various problems with the ANSI library as delivered by 
  939. Symantec with THINKC 5.x.  The two which "broke the camel's back"
  940. were:
  941.  
  942.     1. [f,s]printf is essentially useless with [l]g, [l]f, [l]e 
  943.        format items (h format item is non-ANSI).
  944.  
  945.     2. Garbage results in return values of int and double from
  946.        ANSI functions.
  947.  
  948. Both of these problems are corrected by recompiling the source for
  949. ANSI with "useful" compiler options (e.g. 68020, 68881, native mode
  950. floating point, ...).  Symantec is nice in that for some libraries,
  951. they give you the source, so people can make their own ANSI lib that
  952. uses their typical compiler options.
  953.  
  954. In addition, various people in comp.sys.mac.programmer have reported
  955. problems with malloc.  For Mac purposes, I essentially don't use
  956. malloc because of relocation problems when calls are made across
  957. segments (remember, ANSI is c.28k bytes and usually gets stuck into
  958. its own segment!).  Where I do use malloc, it is for *VERY* temporary
  959. storage, that is not expected to persist to the next function call.
  960. I have not had problems using malloc in this way, and use Handles for
  961. data I need to keep around for any length of time.
  962.  
  963. Another big problem with malloc for numerical programming is that 
  964. many C compilers (including THINKC) won't malloc > 32K bytes of
  965. space (that's 4K doubles - which is not enough for numerical analysis).
  966. Typically, this fails by allocating 32K bytes and then allowing you
  967. to overwrite memory beyond the end of the 32K bytes (which causes
  968. bus errors if you're lucky and really strange behavior if your not).  
  969.  
  970.                                         -- Mike Webb
  971.  
  972. +++++++++++++++++++++++++++
  973.  
  974. From: rsfinn@concerto.lcs.mit.edu (Russell S. Finn)
  975. Organization: MIT Laboratory for Computer Science
  976. Date: Tue, 28 Apr 1992 20:16:38 GMT
  977.  
  978. In article <1992Apr28.160517.6873@mailhost.bl.cad.slb.com>, mikewebb@boston.sinet.slb.com (Mike Webb) writes:
  979. |> While not relating to my original problem (hangs in member), I have
  980. |> run into various problems with the ANSI library as delivered by 
  981. |> Symantec with THINK C 5.x.  The two which "broke the camel's back"
  982. |> were:
  983. |> 
  984. |>     1. [f,s]printf is essentially useless with [l]g, [l]f, [l]e 
  985. |>        format items (h format item is non-ANSI).
  986. |> 
  987. |>     2. Garbage results in return values of int and double from
  988. |>        ANSI functions.
  989. |> 
  990. |> Both of these problems are corrected by recompiling the source for
  991. |> ANSI with "useful" compiler options (e.g. 68020, 68881, native mode
  992. |> floating point, ...).  Symantec is nice in that for some libraries,
  993. |> they give you the source, so people can make their own ANSI lib that
  994. |> uses their typical compiler options.
  995.  
  996. At first, I was totally confused by this, but the reference to
  997. recompiling ANSI suggests to me that you were probably trying to use
  998. the supplied ANSI library, which uses 2-byte ints, with code that uses
  999. 4-byte ints, and that when you recompiled ANSI, you set the 4-byte int
  1000. option on -- which is exactly what the manual tells you to do in this
  1001. case.  I suspect that the compiler options you mention actually have
  1002. little to do with this (in fact, if you look at the ANSI source code,
  1003. you'll find it takes great pains to work correctly no matter what the
  1004. 68881 settings are).
  1005.  
  1006. - -- Russell S. Finn
  1007. rsfinn@lcs.mit.edu
  1008.  
  1009. +++++++++++++++++++++++++++
  1010.  
  1011. From: mikewebb@boston.sinet.slb.com (Mike Webb)
  1012. Date: 29 Apr 92 15:42:54 GMT
  1013. Organization: Schlumberger Technologies CAD/CAM Division
  1014.  
  1015. In article <1992Apr28.201638.26520@mintaka.lcs.mit.edu>, rsfinn@concerto.lcs.mit.edu (Russell S. Finn) writes:
  1016. |> (Text from original posts deleted...)
  1017. |> 
  1018. |> At first, I was totally confused by this, but the reference to
  1019. |> recompiling ANSI suggests to me that you were probably trying to use
  1020. |> the supplied ANSI library, which uses 2-byte ints, with code that uses
  1021. |> 4-byte ints, and that when you recompiled ANSI, you set the 4-byte int
  1022. |> option on -- which is exactly what the manual tells you to do in this
  1023. |> case.  I suspect that the compiler options you mention actually have
  1024. |> little to do with this (in fact, if you look at the ANSI source code,
  1025. |> you'll find it takes great pains to work correctly no matter what the
  1026. |> 68881 settings are).
  1027. |> 
  1028. |> -- Russell S. Finn
  1029. |> rsfinn@lcs.mit.edu
  1030. |> 
  1031.  
  1032. The anecdotes about re-compiling ANSI came from when I had just upgraded
  1033. from THINKC 4.x to THINKC 5.x.  In 4.x, different ANSI libs were supplied,
  1034. while 5.x supplies only one.  The 4.x project compiled, but showed the strange
  1035. behavior discussed (which sounded like alot of other THINKC 5.x problems
  1036. with ANSI functions that have been discussed on the net over the last few
  1037. weeks, and e-mail relating to this post).
  1038.  
  1039. The original thread is that with the indicated compiler options (specifically
  1040. 4 byte ints, 68881, 8 byte doubles, native mode FP, 68020) the member 
  1041. function (used in the bowels of TCL) goes into an infinite loop *EVEN AFTER* ANSI, OOPSDebug (contains member) were re-compiled.  Program only works when
  1042. "unacceptable" (read no 68881) compile options are used.  Also, "infinite loop" should probably be taken with a grain of salt.  I suspect it is really in a 
  1043. for loop to O(2**31), but don't really have the patience to let the program prove this.  I suspect that this is a "int which should be short" problem in
  1044. TCL or some of the OOP RT support functions (e.g. member).  Why it only shows
  1045. up in one of my projects (which is very similar to others - read identical
  1046. at the OOP level) is mysterious.
  1047.  
  1048.                                                Mike Webb
  1049.  
  1050. +++++++++++++++++++++++++++
  1051.  
  1052. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  1053. Date: 2 May 92 04:16:22 GMT
  1054. Organization: Symantec Corp.
  1055.  
  1056. In article <1992Apr28.160517.6873@mailhost.bl.cad.slb.com> mikewebb@boston.sinet.slb.com (Mike Webb) writes:
  1057.  
  1058.    In addition, various people in comp.sys.mac.programmer have
  1059.    reported problems with malloc.
  1060.  
  1061. This is true, but none of these problems has been due to a bug in
  1062. malloc(). The code for malloc() hasn't been changed in 3 years, since
  1063. it was shipped with THINK C 4.0. I expect that all of the programmer
  1064. groups on Usenet see a lot of traffic regarding problems with dynamic
  1065. allocation (except the LISP ones, of course :-).
  1066.  
  1067.    For Mac purposes, I essentially don't use malloc because of
  1068.    relocation problems when calls are made across segments (remember,
  1069.    ANSI is c.28k bytes and usually gets stuck into its own segment!).
  1070.  
  1071. It sounds like you're confusing Mac segments with DOS segment
  1072. pointers. There isn't any problem with sharing malloc'd pointers
  1073. across Mac CODE segments.
  1074.  
  1075. The problem that you ran into originally is, I believe, caused by a
  1076. bug in the header file oops.h. When you compile with the 4-byte ints
  1077. option on, the Class ID parameter to member() is a short int. However,
  1078. member uses a varargs prototype, so this argument is widened to a
  1079. 4-byte int. This can be fixed by modifying the oops.h header file by
  1080. replacing the line:
  1081.  
  1082.     char __member(...);
  1083.  
  1084. with the lines:
  1085.  
  1086.     #if !__option(int_4)
  1087.     char __member(...);
  1088.     #else
  1089.     char __member(void *, short);
  1090.     #endif
  1091.  
  1092. This is not an official fix, but it should work correctly.
  1093.  
  1094.     -phil
  1095. - --
  1096.    Phil Shapiro                                   Software Engineer
  1097.    Language Products Group                     Symantec Corporation
  1098.            Internet: phils@cs.brandeis.edu
  1099.  
  1100. +++++++++++++++++++++++++++
  1101.  
  1102. From: Ray.Arachelian@f204.n2603.z1.ieee.org (Ray Arachelian)
  1103. Date: 5 May 92 20:10:00 GMT
  1104. Organization: FidoNet node 1:2603/204 - Not Even Odd, Forest Hills NY
  1105.  
  1106. On 04-25-92, RSFINN@CONCERTO.LCS.MIT.E wrote to ALL:
  1107.  
  1108.  R> This is certainly legal and meaningful C code, but there's no way the 
  1109.  R> compiler can check this.  (Of course, it *could* emit code to 
  1110.  R> dynamically check the arguments at run-time -- not in *my* C 
  1111.  R> compiler, thank you.)  
  1112.  
  1113. You most certainly can do run time checking.  If you're using Think C, 
  1114. check out the "Think C 5.0 Folder:C Libraries:sources:printf.c" file.  
  1115. Just modify it to call sizeof() and check if they're longs or shorts or 
  1116. what.
  1117.  
  1118. Of course you'll have to rewrite it to sprintf and fprintf, and you show 
  1119. high objection to this, but the possibility is there.  It wouldn't be a 
  1120. good idea to just report a run time error.  It would be a good idea to 
  1121. check the size for a short, int, or long, and just change the way you deal 
  1122. with %d's, etc.
  1123.  
  1124.  
  1125.  * Freddie 1.2b7 * You have been found guilty of commerce with the devil.
  1126.  
  1127. - --  
  1128. =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  1129.  Ray Arachelian - Internet: Ray.Arachelian@f204.n2603.z1.ieee.org
  1130.  
  1131. +++++++++++++++++++++++++++
  1132.  
  1133. From: ksand@apple.com (Kent Sandvik)
  1134. Date: 8 May 92 19:43:40 GMT
  1135. Organization: MacDTS Mongols
  1136.  
  1137. In article <1992Apr27.235049.11690@ryn.mro4.dec.com>, akhiani@rock.enet.dec.com
  1138. (Homayoon Akhiani) writes:
  1139. >  Thanks for the replies.
  1140. >  Adding stdlib.h and switching the compiler to 32 bit int's fixed the problem.
  1141. >  
  1142. >  Many of you ask me whay I am not using Newptr, Well, the code that I am
  1143. trying
  1144. >  to compile is suppose to be a portable one.
  1145. >  It should be compile on many platforms. Newptr is Mac thingy.
  1146.  
  1147. Can't avoid it anyway, malloc calls NewPtr.
  1148.  
  1149. Cheers,
  1150. Kent
  1151.  
  1152. ---------------------------
  1153.  
  1154. End of C.S.M.P. Digest
  1155. **********************
  1156.